<include file="Public:header"/>
 
    <link href="{lanrain::RES}/ruiec/css/validate.css" rel="stylesheet" type="text/css" />
    <link href="{lanrain::RES}/ruiec/css/retrievepwd.css" rel="stylesheet" type="text/css" />
    <script src="{lanrain::RES}/ruiec/js/common/jquery.validator.js" type="text/javascript"></script>
    <script src="{lanrain::RES}/ruiec/js/common/formValidatorRegex.js" type="text/javascript"></script>
    <script src="{lanrain::RES}/ruiec/js/common/Jquery.Cookie.js" type="text/javascript"></script>
    <script src="{lanrain::RES}/ruiec/js/common/base.js" type="text/javascript"></script>
</head>
<body>
    <form method="post" action="retrievepwd.aspx" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMjExNjYwODM4M2Rk" />

    
    <div id="firstDiv" class="ln-md">

        <div class="lo_box margintop lft">
            <div class="libcons marptits2 lft">
                <table cellpadding="0" cellspacing="10" border="0" width="700px">
                    <tr>
                        <td colspan="3" align="left">
                            <span class="lotitlesrd marptits">找回密码</span>
                        </td>
                    </tr>
                    <tr>
                        <td width="18%" style="text-align: right;">
                            用户名：
                        </td>
                        <td width="35%" align="left">
                            <input name="ctl00$ContentPlaceHolder1$tbxAccountName" type="text" maxlength="30" id="ContentPlaceHolder1_tbxAccountName" class="loinput" />
                        </td>
                        <td width="50%">
                            <div class="tipText">
                                <span class="lef">&nbsp;</span><span class="cent" id="ContentPlaceHolder1_tbxAccountNameTip"></span><span
                                    class="rig">&nbsp;</span></div>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right;">
                            验证码：
                        </td>
                        <td>
                            <input name="ctl00$ContentPlaceHolder1$tbxValidateCode" type="text" maxlength="5" id="ContentPlaceHolder1_tbxValidateCode" class="loinput lft" style="width: 120px;" />
                            <span class="codepg ">
                                <img id="createCode" width="100"  alt="看不清楚？点击换一张" title="看不清楚？点击换一张" onclick="ChangeValidateCode();" /></span>
                        </td>
                        <td>
                            <div class="tipText">
                                <span class="lef">&nbsp;</span><span class="cent" id="ContentPlaceHolder1_tbxValidateCodeTip"></span><span
                                    class="rig">&nbsp;</span></div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <div class="lotwo">
                                <input id="firstBtn" type="button" class="okinfos-butyess" value="下一步" /></div>
                        </td>
                        <td>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="clear">
            </div>
        </div>
    </div>
    
   

    <script type="text/javascript">
        var _fv = undefined;
        function formV() {
            _fv = $('#form1').FromValidate();

            $("#ContentPlaceHolder1_tbxAccountName").InitValidate({
                fv: _fv,
                TipText: "请输入您注册的账号。",
                Correct: "输入正确"
            }).requireValidator({
                errorText: "不能为空，请重新输入"
            }).regexValidator({
                regex: regexEnum.username,
                errorText: "仅由英文、数字、下划线组成"
            }).lenValidator({
                min: 4,
                max: 18,
                errorText: "账号长度为4-12位"
            });

          

        }

        $(function () {
            formV();
        });

        $("#firstBtn").click(function () {
            if ($.FromValidate(_fv)) {
                var name = $.trim($("#ContentPlaceHolder1_tbxAccountName").val());
                var params = "accountname=" + name + "&type=returnEmail";
                Base.AjaxForHTML("retrievepwd.aspx", "get", params, function (data) {
                    setBtnStyle("firstDiv", false);
                    setBtnStyle("selectType", true);
                    switch (data) {
                        case "nullEmail": $("#ulSelectType").html("<li><span class=\"lotitlesrd marptits\">对不起您的账号还未设置邮箱，请联系我们的客户人员。</span></li>"); break;
                        case "n":
                            setBtnStyle("firstDiv", true);
                            setBtnStyle("selectType", false);
                            break;
                        default:
                            if (data.indexOf("@") >= 0)
                                $("#selectTypeEmailSpan").html("<a href=\"javascript:void(0);\">" + data + "</a>");
                            else
                                alert("参数错误，请刷新页面后再试...");
                            break;
                    }
                });
            }
        });

        $("#selectTypeBtn").click(function () {
            var success = $.FromValidate(_fv);
            if (!success) {
                setBtnStyle("firstDiv", true);
                setBtnStyle("selectType", false);
                return;
            }

            var name = $.trim($("#ContentPlaceHolder1_tbxAccountName").val());
            var code = $.trim($("#ContentPlaceHolder1_tbxValidateCode").val());
            if (name == "" || code == "") {
                setBtnStyle("firstDiv", true);
                setBtnStyle("selectType", false);
                setBtnStyle("confrimSuccessDiv", false);
                return;
            }

            var rdoObj = $("input[name='rpwType']:checked");
            var rdoVal = rdoObj.val();
            if (rdoVal == undefined || rdoVal == null) { alert("请选择找回方式！"); return; }
            var params = "accountname=" + name + "&sendType=" + rdoVal + "&rpwcode=" + code;
            $(this).hide(); $("#errprSecondSpan").html("正在提交您的请求，请稍后...");
            Base.AjaxForHTML("retrievepwd.aspx", "get", params, function (data) {
                switch (data) {
                    case "codeError":
                    case "userNull":
                    case "userDisable":
                    case "emailNull":
                        alert("您的账号有错误，无法发送邮件，请联系我们的客服人员。");
                        setBtnStyle("firstDiv", true);
                        setBtnStyle("selectType", false);
                        setBtnStyle("confrimSuccessDiv", false);
                        break;
                    case "error":
                    case "sendError":
                        alert("发送重置密码邮件失败，请稍后再试！");
                        setBtnStyle("firstDiv", true);
                        setBtnStyle("selectType", false);
                        setBtnStyle("confrimSuccessDiv", false);
                        break;
                    case "sendEmailNumber":
                        $("#returnInfoDiv").html("对不起，您已用完每天限发重置密码邮件次数！");
                        setBtnStyle("firstDiv", false);
                        setBtnStyle("selectType", false);
                        setBtnStyle("confrimSuccessDiv", true);
                        break;
                    default:
                        if (data.indexOf("success") >= 0) {
                            var dataArray = data.split('|');
                            if (null != dataArray && dataArray.length == 4) {
                                if (dataArray.length == 4) {
                                    var html = "<p class=\"tishitext\">请登录您的邮箱查收重置密码邮件，该邮件24小时内有效。若没有收到，您可以 "
                                                + "<input id=\"iptResendEmailBtn\" type=\"button\" value=\"点击重发验证邮件\" class=\"fsyzm\" onclick=\"ResendEmail();\"/><span id=\"resendSendSpan\"></span> "
                                                + " 。每天限发送五封重置密码邮件。</p>"
                                                + "<p class=\"f-14 email\"> 接收邮箱:<strong id=\"strongEmail\" mail=\"" + dataArray[3] + "\">" + dataArray[1] + "</strong></p>"
                                                + "<p><input id=\"openEmailBtn\" type=\"button\" class=\"okinfos-butyess\" value=\"GO 邮箱\" onclick=\"GoEmail();\"/></p>";

                                    $("#returnInfoDiv").html(html);
                                    $("#errprSecondSpan").html("");
                                    setBtnStyle("firstDiv", false);
                                    setBtnStyle("selectType", false);
                                    setBtnStyle("confrimSuccessDiv", true);
                                }
                            }
                            else {
                                alert("操作异常，请刷新页面后再试");
                                location.reload();
                            }
                        }
                        else {
                            alert("操作异常，请刷新页面后再试");
                            location.reload();
                        }
                        break;
                }
            });
        });

        function ResendEmail(obj) {
            var obj = $("#iptResendEmailBtn");

            var name = $.trim($("#ContentPlaceHolder1_tbxAccountName").val());
            var code = $.trim($("#ContentPlaceHolder1_tbxValidateCode").val());
            if (name == "" || code == "") {
                setBtnStyle("firstDiv", true);
                setBtnStyle("selectType", false);
                setBtnStyle("confrimSuccessDiv", false);
            }

            var params = "accountname=" + name + "&sendType=0&rpwcode=" + code;
            obj.hide(); $("#resendSendSpan").html("发送中，请稍后...");
            Base.AjaxForHTML("retrievepwd.aspx", "get", params, function (data) {
                switch (data) {
                    case "codeError":
                    case "userNull":
                    case "userDisable":
                    case "emailNull":
                        alert("您的账号有错误，无法发送邮件，请联系我们的客服人员。");
                        setBtnStyle("firstDiv", true);
                        setBtnStyle("selectType", false);
                        setBtnStyle("confrimSuccessDiv", false);
                        break;
                    case "error":
                    case "sendError":
                        alert("发送重置密码邮件失败，请稍后再试！");
                        setBtnStyle("firstDiv", true);
                        setBtnStyle("selectType", false);
                        setBtnStyle("confrimSuccessDiv", false);
                        break;
                    case "sendEmailNumber":
                        $("#returnInfoDiv").html("对不起，您已用完每天限发重置密码邮件次数！");
                        setBtnStyle("firstDiv", false);
                        setBtnStyle("selectType", false);
                        setBtnStyle("confrimSuccessDiv", true);
                        break;
                    default:
                        if (data.indexOf("success") >= 0) {
                            var dataArray = data.split('|');
                            if (null != dataArray && dataArray.length == 4) {
                                if (dataArray.length == 4) {
                                    alert("重发验证信息成功！您今天已申请发送了 " + dataArray[2] + " 封重置密码邮件。");
                                    obj.show(); $("#resendSendSpan").html("");
                                }
                            }
                            else {
                                alert("操作异常，请刷新页面后再试");
                                location.reload();
                            }
                        }
                        else {
                            alert("操作异常，请刷新页面后再试");
                            location.reload();
                        }
                        break;
                }
            });

        }

        function GoEmail() {
            var mailUrl = $("#strongEmail").attr("mail");
            location.href = "http://mail." + mailUrl;
        }

        function setBtnStyle(objId, isTrue) {
            var obj = $("#" + objId);
            if (isTrue) { obj.show(); } else { obj.hide(); }
        }
        
    </script>
    <div class="clear">
    </div>

<include file="Public:footer"/>
    </form>
</body>
</html>
